//
//  LSZNewAudioHomepageManager.m
//  JKFuYinProject
//
//  Created by 九酷 on 2018/5/28.
//  Copyright © 2018年 LC. All rights reserved.
//

#import "LSZNewAudioHomepageManager.h"

@implementation LSZNewAudioHomepageManager
-(id)initWithNewAudioHomepage :(NSDictionary *)dic;
{
    self = [super init];
    if (self) {
        if ([[dic valueForKey:@"data"] isKindOfClass:[NSString class]]) {
            return self;
        }
        if ([[dic valueForKey:@"data"] isKindOfClass:[NSNumber class]]) {
            return self;
        }
        if (![dic valueForKey:@"data"]) {
            return self;
        }
        NSArray * arrayData = dic[@"data"];
        NSMutableArray * AddArrayMg = [[NSMutableArray alloc]init];
        for (NSDictionary * dictionMg in arrayData) {
            LSZNewAudioHomepageMg * mg = [[LSZNewAudioHomepageMg alloc]init];
            mg.name = NullStringjudgment(NSStr(dictionMg[@"name"]));
            mg.type = NullStringjudgment(NSStr(dictionMg[@"type"]));
            NSArray * detailArray = dictionMg[@"detail"];//音乐
            NSMutableArray * addArrayDetail = [[NSMutableArray alloc]init];
            //音乐
            for (NSDictionary * dicDetail in detailArray) {
                LSZNewAudioHomepageMg * mgDetail = [[LSZNewAudioHomepageMg alloc]init];
                mgDetail.parentId = NullStringjudgment(NSStr(dicDetail[@"parentId"]));
                mgDetail.singerName = NullStringjudgment(NSStr(dicDetail[@"singerName"]));
                mgDetail.id_id = NullStringjudgment(NSStr(dicDetail[@"id"]));
                mgDetail.title = NullStringjudgment(NSStr(dicDetail[@"title"]));
                mgDetail.duration = NullStringjudgment(NSStr(dicDetail[@"duration"]));
                mgDetail.fileUrl = NullStringjudgment(NSStr(dicDetail[@"fileUrl"]));
                mgDetail.album = NullStringjudgment(NSStr(dicDetail[@"album"]));
                mgDetail.originalClick = NullStringjudgment(NSStr(dicDetail[@"click"]));
                mgDetail.click  = [LSZSpecialPackaging theNumberViewsForTheAlbumAhanges:mgDetail.originalClick];
                mgDetail.n = NullStringjudgment(NSStr(dicDetail[@"n"]));
                mgDetail.shareUrl = NullStringjudgment(NSStr(dicDetail[@"shareUrl"]));

                [addArrayDetail addObject:mgDetail];
            }
            mg.arrayDetail = (NSArray *)addArrayDetail;
            //音乐
            NSArray * listArray = dictionMg[@"list"];//专辑
            NSMutableArray * addArrayList = [[NSMutableArray alloc]init];
            for (NSDictionary * dicList in listArray) {
                LSZNewAudioHomepageMg * mgList = [[LSZNewAudioHomepageMg alloc]init];
                if([[dicList allKeys] containsObject:@"album_name"]){
                    mgList.album_name = NullStringjudgment(NSStr(dicList[@"album_name"]));
                }
                if([[dicList allKeys] containsObject:@"artist_name"]){
                    mgList.artist_name = NullStringjudgment(NSStr(dicList[@"artist_name"]));
                }
                mgList.id_id = NullStringjudgment(NSStr(dicList[@"id"]));
                mgList.content = NullStringjudgment(NSStr(dicList[@"content"]));
                mgList.originalHits = NullStringjudgment(NSStr(dicList[@"hits"]));
                mgList.hits  = [LSZSpecialPackaging theNumberViewsForTheAlbumAhanges:mgList.originalHits];
                mgList.image = NullStringjudgment(NSStr(dicList[@"image"]));
                mgList.likes = NullStringjudgment(NSStr(dicList[@"likes"]));
                mgList.singerName = NullStringjudgment(NSStr(dicList[@"singerName"]));
                mgList.total_song = NullStringjudgment(NSStr(dicList[@"total_song"]));
                mgList.type = NullStringjudgment(NSStr(dicList[@"type"]));
                [addArrayList addObject:mgList];
            }
            mg.arrayList = (NSArray *)addArrayList;
            [AddArrayMg addObject:mg];
        }
        self.arrayData = AddArrayMg;
    }
    return self;
}
-(id)initWithDynamicAccessAlbumSingerDetails :(NSString *)type :(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        if ([[dic valueForKey:@"data"] isKindOfClass:[NSString class]]) {
            return self;
        }
        if ([[dic valueForKey:@"data"] isKindOfClass:[NSNumber class]]) {
            return self;
        }
        if (![dic valueForKey:@"data"]) {
            return self;
        }
        NSDictionary * dicList = dic[@"data"];
        NSMutableArray * AddArrayMg = [[NSMutableArray alloc]init];

        if ([type isEqualToString:@"2"]) {
            LSZNewAudioHomepageMg * mgDetail = [[LSZNewAudioHomepageMg alloc]init];
            mgDetail.parentId = NullStringjudgment(NSStr(dicList[@"parentId"]));
            mgDetail.singerName = NullStringjudgment(NSStr(dicList[@"singerName"]));
            mgDetail.id_id = NullStringjudgment(NSStr(dicList[@"id"]));
            mgDetail.title = NullStringjudgment(NSStr(dicList[@"title"]));
            mgDetail.duration = NullStringjudgment(NSStr(dicList[@"duration"]));
            mgDetail.fileUrl = NullStringjudgment(NSStr(dicList[@"fileUrl"]));
            mgDetail.album = NullStringjudgment(NSStr(dicList[@"album"]));
            mgDetail.originalClick = NullStringjudgment(NSStr(dicList[@"click"]));
            mgDetail.click  = [LSZSpecialPackaging theNumberViewsForTheAlbumAhanges:mgDetail.originalClick];
            mgDetail.n = NullStringjudgment(NSStr(dicList[@"n"]));
            mgDetail.shareUrl = NullStringjudgment(NSStr(dicList[@"shareUrl"]));
            [AddArrayMg addObject:mgDetail];
        }else{
            LSZNewAudioHomepageMg * mgList = [[LSZNewAudioHomepageMg alloc]init];
            if([[dicList allKeys] containsObject:@"album_name"]){
                mgList.album_name = NullStringjudgment(NSStr(dicList[@"album_name"]));
            }
            if([[dicList allKeys] containsObject:@"artist_name"]){
                mgList.artist_name = NullStringjudgment(NSStr(dicList[@"artist_name"]));
            }
            mgList.id_id = NullStringjudgment(NSStr(dicList[@"id"]));
            mgList.content = NullStringjudgment(NSStr(dicList[@"content"]));
            mgList.originalHits = NullStringjudgment(NSStr(dicList[@"hits"]));
            mgList.hits  = [LSZSpecialPackaging theNumberViewsForTheAlbumAhanges:mgList.originalHits];
            mgList.image = NullStringjudgment(NSStr(dicList[@"image"]));
            mgList.likes = NullStringjudgment(NSStr(dicList[@"likes"]));
            mgList.singerName = NullStringjudgment(NSStr(dicList[@"singerName"]));
            mgList.total_song = NullStringjudgment(NSStr(dicList[@"total_song"]));
            mgList.type = NullStringjudgment(NSStr(dicList[@"type"]));
            [AddArrayMg addObject:mgList];
        }
        self.arrayData = AddArrayMg;
    }
    return self;
}
@end
@implementation LSZNewAudioHomepageMg
@end
